package cn.hushi.test;

import cn.hushi.domain.Customer;
import cn.hushi.utils.HibernateUtil;
import org.hibernate.Session;
import org.hibernate.Transaction;

public class Demo1 {
    public static void main(String[] args) {
        Demo1 demo1 = new Demo1();
        demo1.test1();
    }

    public void test1() {
        Customer customer = new Customer();
//            customer.setId(1);
        customer.setName("miss.cang");
        customer.setAge(18);
        customer.setGender("girl");
        customer.setLevel("VIP customer");

        //获取session
        Session session = HibernateUtil.getSession();

        //开启事务
        Transaction tx = session.beginTransaction();

        //执行添加操作
        session.save(customer);

        //提交事务
        tx.commit();

        //关闭资源
        session.close();

    }
}